package gson.client;

import com.google.gson.JsonObject;

import gson.Test.BaseMessage;

public class OrderMessage extends BaseMessage{
	public static final String MODE = "mode";
	
	public static final String PARAMSLIST = "paramslist";
	
	public  int mode;
	
	public String orderMsg = "";
	
	public String getOrderMsg() {
		return orderMsg;
	}

	public void setOrderMsg(String orderMsg) {
		this.orderMsg = orderMsg;
	}

	public int getMode() {
		return mode;
	}

	public void setMode(int mode) {
		this.mode = mode;
	}
	//客户端打包
	@SuppressWarnings("static-access")
	public static String packToJson(OrderMessage ordermsg) {
		JsonObject Json = new JsonObject();
		Json.addProperty(MODE, ordermsg.mode);
		Json.addProperty(PARAMSLIST, ordermsg.orderMsg);
		return Json.toString();
	}
	//服务端解析
	public static OrderMessage parseJson(String Jstr) {
		OrderMessage mOrder = new OrderMessage();
		JsonObject jobj = mParser.parse(Jstr).getAsJsonObject();
		mOrder.mode = jobj.get(MODE).getAsInt();
		mOrder.orderMsg = jobj.get(PARAMSLIST).getAsString();
		return mOrder;
	}
}
